﻿/// <reference path="../_reference.js" />
(function ($, window) {
    var ViewModel = function () {
        var that = this;
        that.gameid = ko.observable(gameid);
        that.playid = ko.observable(playid);
        that.gamePlayList = ko.observableArray([{ ID: 0, Name: "所有玩法" }]);
        that.gameEvent = function (data, event) {
            if (Number(that.gameid()) == 0) {
                var arr = [{ ID: 0, Name: "所有玩法" }];
                that.gamePlayList(arr);
                return false;
            }
            var url = U('api/lottery/playlist');
            var arr = [];
            arr.push({ ID: 0, Name: "所有玩法" });
            $.getJSON(url, { gameID: that.gameid() }, function (json) {
                $.each(json, function (a, b) {
                    arr.push(b);
                });
                that.gamePlayList(arr);
                if (playid != '') {
                    that.playid(playid);
                }
            });
        };
        that.searchData = function (data, event) {
            $("#SEARCH-TIP").show();
            $("#form1").submit();
        };
        that.init = function () {
            var errMsg = $("#hdErrMsg").val();
            if (errMsg != undefined && errMsg != '') {
                utils.tip(errMsg, '#ff0000', function () { });
            }
            if (that.gameid() != 0) {
                that.gameEvent(null, null);
            }
        };
        that.init();
    };
    $(function () {
        var model = new ViewModel();
        ko.applyBindings(model, document.getElementById("ulMain"));
    });
})(jQuery, window);